package com.cyy.dyeing.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cyy.dyeing.model.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: cyy
 * @Date: 2024/7/24
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Delete("delete from t_rm where ro_id=#{roId}")
    void deleteRoleModules(@Param("roId")Integer roId);

    @Insert("insert into t_rm values (#{ids}, #{roId}) ")
    void insertRoleModule(@Param("roId") Integer roId,
                          @Param("ids") Integer ids);

//
    @Select("select ro_id, ro_name, ro_remark," +
            "  (select count(ro_id) from t_ur where u_id = #{u_id} and ro_id = r.ro_id ) as has" +
            "  from t_role r where ro_status = #{code} order by ro_id")
    List<Role> findRoleList(@Param("u_id") String u_id,
                        @Param("code") String code);
}
